<template>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="comapnyName" label="任务" width="180"></el-table-column>
    <!--<el-table-column prop="companyNo" label="公司编号" width="180"></el-table-column>-->
    <!--<el-table-column prop="namee" label="负责人"></el-table-column>-->
    <el-table-column prop="phone" label="状态"></el-table-column>
    <!--<el-table-column prop="introduce" label="简介"></el-table-column>-->
    <!--<el-table-column prop="applyDocUrl" label="公司详细文档"></el-table-column>-->
    <el-table-column label="对方上传的文档和代码">
      <template slot-scope="scope">
        <a  :href=scope.row.applyDocUrl>点击下载代码和文档</a>
      </template>
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="handleEdit(scope.$index, scope.row)">接受</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)">拒绝</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
  export default {
    data() {
      return {
        tableData: [
          {
            id:'',
            comapnyName:'',
            companyNo:'',
            namee:'',
            phone:'',
            introduce:'',
            applyDocUrl:''
          }
        ]
      }
    },
    mounted: function(){
      var user= JSON.parse(window.sessionStorage.getItem("user"));
      var ff=user.id
      axios.post('/admin/companyApply',{
        id : ff,
        idd:ff
      }).then((response) => {
        if( response.data != null){
          this.$notify({
            title: '成功',
            message: '成功',
            type: 'success',
            duration:2000
          });
          var e=response.data.user
          console.log(e[0])
          var f=response.data.usertwo
          var data=[];
          console.log(e.size)
          for(var c=0;c<f;c++){

            var ee=e[c];
            var eee=ee[0]
            var eeee=ee[1]
            var obj={}
            obj.phone=eee.phone
            obj.id=eeee.id
            obj.comapnyName=eeee.comapnyName
            obj.companyNo=eeee.companyNo
            obj.namee=eeee.name
            obj.introduce=eeee.introduce
            obj.applyDocUrl=eeee.applyDocUrl
            data[c]=obj
            console.log(obj)
          }
          console.log(data)
          this. tableData=data


        }
        else{
          this.$notify({
            title: '失败',
            message: '错误',
            type: 'warning',
            duration:2000
          });
        }
      })

    },
    methods: {
      handleEdit(index, row) {
        console.log(row.id)
        var ff=row.id


        axios.post('/admin/acceptApply',{
          id : ff,
          idd  : ff
        }).then((response) => {
          if( response.data.states== 800){
            this.$notify({
              title: '成功',
              message: '成功',
              type: 'success',
              duration:2000

            });
            location.reload()
          } else{
            this.$notify({
              title: '失败',
              message: '错误',
              type: 'warning',
              duration:2000
            });
          }
        })


      },
      handleDelete(index, row) {
        console.log(index, row);
        var ff=row.id
        axios.post('/admin/refuseApply',{
          id : ff,
          idd  : ff
        }).then((response) => {
          if( response.data.states== 800){
            this.$notify({
              title: '成功',
              message: '成功',
              type: 'success',
              duration:2000
            });
            location.reload()
          }
          else{
            this.$notify({
              title: '失败',
              message: '错误',
              type: 'warning',
              duration:2000
            });
          }
        })


      }

    }

  }
</script>



<style scoped>

</style>
